package sharedServlets;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.*;

import controller.Controller;

@SuppressWarnings("serial")
public class ForgetPassword extends HttpServlet {
	public void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws IOException {
		resp.sendRedirect("home.jsp");
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		String type = req.getParameter("type");
		String userName = req.getParameter("forgetUserName");
		int result = 2;
		if (type.equals("Customer"))
			result = Controller.getInstance().forgetPasswordClient(userName);
		else if(type.equals("Business"))
			result = Controller.getInstance().forgetPasswordBiz(userName);
		if(result==1){
			req.getSession().setAttribute("forgetError", "User name is wrong");
			resp.sendRedirect("home.jsp#forget");
		}
		else
			resp.sendRedirect("home.jsp");


	}
	
}
